<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>S3 signer</title>
  </head>
  <body>
    <noscript>
      <strong
        >We're sorry but metadata doesn't work properly without JavaScript
        enabled. Please enable it to continue.</strong
      >
    </noscript>
    <script type="module" src="./src/index.js"></script>
    <script>
      import { QueryParameterSigner } from './src/index.js'
      var AWSAccessKey = 'AKIAIOSFODNN7EXAMPLE'
      var AWSSecretKey = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
      var bucketName = 'examplebucket'
      var awsRegion = 'us-east-1'
      var objectKey = 'test.txt'
      var endpointUri = new URL(
        'https://' + bucketName + '.s3.amazonaws.com/' + objectKey
      )
      var queryParams = 'X-Amz-Expires=86400'
      var signer = new QueryParameterSigner(endpointUri, 'GET', 's3', awsRegion)
      var authorization = signer.ComputeSignature(
        new Map(),
        queryParams,
        'UNSIGNED-PAYLOAD',
        AWSAccessKey,
        AWSSecretKey
      )
      console.log(authorization)
    </script>
    <script>
      import { AuthorizationHeaderSigner } from './src/index.js'
      var AWSAccessKey = 'AKIAIOSFODNN7EXAMPLE'
      var AWSSecretKey = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
      var bucketName = 'examplebucket'
      var awsRegion = 'us-east-1'
      var objectKey = 'test.txt'
      var endpointUri = new URL(
        'https://' + bucketName + '.s3.amazonaws.com/' + objectKey
      )
      var queryParams = ''
      var signer = new AuthorizationHeaderSigner(
        endpointUri,
        'GET',
        's3',
        awsRegion
      )
      var authorization = signer.ComputeSignature(
        new Map([
          [signer.X_Amz_Content_SHA256, signer.EMPTY_BODY_SHA256],
          ['content-type', 'text/plain'],
        ]),
        queryParams,
        signer.EMPTY_BODY_SHA256,
        AWSAccessKey,
        AWSSecretKey
      )
      console.log(authorization)
    </script>
  </body>
</html>
